package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoGalleryInterior;
import com.muyu.danmo.service.IDanmoGalleryInteriorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 画廊内景Controller
 *
 * @author yangle
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/galleryInterior")
public class DanmoGalleryInteriorController extends BaseController
{
    @Autowired
    private IDanmoGalleryInteriorService danmoGalleryInteriorService;

    /**
     * 查询画廊内景列表
     */
//    @RequiresPermissions("system:galleryInterior:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoGalleryInterior>> list(DanmoGalleryInterior danmoGalleryInterior)
    {
        startPage();
        List<DanmoGalleryInterior> list = danmoGalleryInteriorService.selectDanmoGalleryInteriorList(danmoGalleryInterior);
        return getDataTable(list);
    }

    /**
     * 导出画廊内景列表
     */
//    @RequiresPermissions("system:galleryInterior:export")
    @Log(title = "画廊内景", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoGalleryInterior danmoGalleryInterior)
    {
        List<DanmoGalleryInterior> list = danmoGalleryInteriorService.selectDanmoGalleryInteriorList(danmoGalleryInterior);
        ExcelUtil<DanmoGalleryInterior> util = new ExcelUtil<DanmoGalleryInterior>(DanmoGalleryInterior.class);
        util.exportExcel(response, list, "画廊内景数据");
    }

    /**
     * 获取画廊内景详细信息
     */
//    @RequiresPermissions("system:galleryInterior:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoGalleryInteriorService.selectDanmoGalleryInteriorById(id));
    }

    /**
     * 新增画廊内景
     */
//    @RequiresPermissions("system:galleryInterior:add")
    @Log(title = "画廊内景", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoGalleryInterior danmoGalleryInterior)
    {
        return toAjax(danmoGalleryInteriorService.insertDanmoGalleryInterior(danmoGalleryInterior));
    }

    /**
     * 修改画廊内景
     */
//    @RequiresPermissions("system:galleryInterior:edit")
    @Log(title = "画廊内景", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoGalleryInterior danmoGalleryInterior)
    {
        return toAjax(danmoGalleryInteriorService.updateDanmoGalleryInterior(danmoGalleryInterior));
    }

    /**
     * 删除画廊内景
     */
//    @RequiresPermissions("system:galleryInterior:remove")
    @Log(title = "画廊内景", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoGalleryInteriorService.deleteDanmoGalleryInteriorByIds(ids));
    }
}
